package book;

public class BookList {
    private Book[] books = new Book[20];//抽象一个书架
    private int count;//计数书架中的书

    /**
     * 创建一个书架类BookList
     * 定义两个成员变量books和count
     * books数组用来存放图书 = 书架，访问权限是私密访问权限，类型为book类型，count用来计数书架中有多少书籍
     * 创建一个构造方法BookList用来初始化成员变量books和count
     * 给每个成员变量创建get和set方法用来访问成员
     */
    public BookList() {
        this.books[0] = new Book("三国演义","罗贯中",18.9,"经典小说");
        this.books[1] = new Book("西游记","吴承恩",19.9,"经典小说");;
        this.books[2] = new Book("红楼梦","曹雪芹",21.9,"经典小说");;
        this.books[3] = new Book("水浒传","施耐庵",20.9,"经典小说");;
        this.books[4] = new Book("社会契约论","卢梭",29.7,"西方哲学");
        this.count = 5;

    }
    //通过下标来获取当前所对应的图书
  public Book getBook(int pos) {
        return books[pos];
  }
  //每次创建图书把值传回来，在pos位置新增图书
  public Book setBook(int pos, Book book) {
        return books[pos] = book;
  }
    public Book[] getBooks() {
        return books;
    }

    public void setBooks(Book[] books) {
        this.books = books;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
